/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.pay.view;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.common.d.a.a;
import com.qihoo.gamecenter.sdk.common.h.g;
import com.qihoo.gamecenter.sdk.common.i.i;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.pay.component.APayWidget;
import com.qihoo.gamecenter.sdk.pay.component.PayImgTextView;
import com.qihoo.gamecenter.sdk.pay.j.u;
import com.qihoo.gamecenter.sdk.pay.res.b;
import org.json.JSONObject;

public class PayHeaderView extends APayWidget {
    private Intent c;
    private Context d;
    private Button e;
    private ImageView f;
    private RelativeLayout g;
    private PayImgTextView h;
    private TextView i;
    private a j;
    private a k;
    private u l = null;

    public PayHeaderView(Context paramContext, Intent paramIntent) {
        super(paramContext);
        this.c = paramIntent;
        this.d = paramContext;
        e();
    }

    private void e() {
        setLayoutParams(new RelativeLayout.LayoutParams(-1, s.b(this.d, 40.0F)));
        this.b.a(this, -1073741716);
        RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-2, s.b(this.d, 30.0F));
        localLayoutParams.addRule(9, -1);
        localLayoutParams.addRule(15, -1);
        localLayoutParams.leftMargin = s.b(this.d, 6.0F);
        this.e = new Button(this.d);
        this.e.setLayoutParams(localLayoutParams);
        this.e.setMinimumWidth(s.b(this.d, 50.0F));
        this.e.setTextSize(1, a(13.3F));
        this.e.setGravity(17);
        this.e.setText(com.qihoo.gamecenter.sdk.common.d.a.a(a.a.dJ));
        this.e.setTextColor(-1);
        this.e.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                if (PayHeaderView.a(PayHeaderView.this) == null)
                    return;
                PayHeaderView.a(PayHeaderView.this).a(paramView);
            }
        });
        this.b.a(this.e, -1073741795, -1073741794, -1073741794);
        addView(this.e);
        localLayoutParams = new RelativeLayout.LayoutParams(-2, -1);
        localLayoutParams.addRule(13, -1);
        int i1 = s.b(this.d, 18.0F);
        this.h = new PayImgTextView(this.d);
        this.h.a(65282);
        this.h.setLayoutParams(localLayoutParams);
        this.h.setGravity(17);
        this.h.setTextColor(-1);
        this.h.setTextSize(1, a(16.0F));
        this.h.setImgScaleType(ImageView.ScaleType.FIT_XY);
        this.h.setImageMargin(s.b(this.d, 8.0F), new int[0]);
        this.h.setImageDrawable(this.b.a(1073741925), i1, i1);
        addView(this.h);
        localLayoutParams = new RelativeLayout.LayoutParams(s.b(this.d, 42.0F), -1);
        localLayoutParams.addRule(11, -1);
        this.g = new RelativeLayout(this.d);
        this.g.setLayoutParams(localLayoutParams);
        this.g.setVisibility(8);
        this.g.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                PayHeaderView.a(PayHeaderView.this, false);
                if (PayHeaderView.b(PayHeaderView.this) == null)
                    return;
                PayHeaderView.b(PayHeaderView.this).a(paramView);
            }
        });
        addView(this.g);
        i1 = s.b(this.d, 31.0F);
        localLayoutParams = new RelativeLayout.LayoutParams(i1, i1);
        localLayoutParams.addRule(13, -1);
        this.f = new ImageView(this.d);
        this.f.setLayoutParams(localLayoutParams);
        this.b.a(this.f, 1073741906);
        this.g.addView(this.f);
        if (!(com.qihoo.gamecenter.sdk.support.c.a.e(this.d)))
            return;
        i1 = s.b(this.d, 18.0F);
        localLayoutParams = new RelativeLayout.LayoutParams(i1, i1);
        localLayoutParams.addRule(11, -1);
        localLayoutParams.addRule(10, -1);
        localLayoutParams.topMargin = s.b(this.d, 2.0F);
        localLayoutParams.rightMargin = s.b(this.d, 2.0F);
        this.i = new TextView(this.d);
        this.i.setGravity(17);
        this.i.setTextColor(-1);
        this.i.setLayoutParams(localLayoutParams);
        this.i.setVisibility(8);
        this.i.setText("3");
        this.i.setTextSize(1, a(8.0F));
        this.b.a(this.i, 1073741872);
        this.g.addView(this.i);
        post(new Runnable() {
            public void run() {
                PayHeaderView.this.b();
            }
        });
    }

    public final void a(String paramString) {
        if (this.i == null)
            return;
        this.i.setText(paramString);
        if (TextUtils.isEmpty(paramString)) {
            a(false);
        }
        else {
            if (this.i.isShown())
                return;
            this.i.setVisibility(0);
        }
    }

    public final void a() {
        a(false);
    }

    private final void a(boolean paramBoolean) {
        if ((this.i != null) && (this.i.isShown()) && (!(paramBoolean)))
            this.i.setVisibility(8);
        else
            this.g.removeView(this.i);
    }

    public void b() {
        if (this.l != null)
            return;
        this.l = new u(this.d, this.c);
        this.l.a(new g() {
            public void a(String paramString, Context paramContext) {
                JSONObject localJSONObject = i.a(paramString);
                if (localJSONObject != null) {
                    int i = localJSONObject.optInt("error_code", -1);
                    if (i == 0) {
                        localJSONObject = localJSONObject.optJSONObject("content");
                        if ((localJSONObject != null) && (PayHeaderView.c(PayHeaderView.this) != null)) {
                            int j = localJSONObject.optInt("reply_num");
                            PayHeaderView.this.a((j > 0) ? String.valueOf(j) : "");
                        }
                    }
                }
                PayHeaderView.a(PayHeaderView.this, null);
            }
        }, new String[0]);
    }

    public void setTitleTxt(String paramString) {
        this.h.setText(paramString);
    }

    public void setBackBtnLabel(String paramString) {
        this.e.setText(paramString);
    }

    public void c() {
        this.e.setVisibility(0);
    }

    public void d() {
        this.g.setVisibility(0);
    }

    public void setMenuBtn(a parama, int[] paramArrayOfInt) {
        d();
        this.j = parama;
        int i1 = paramArrayOfInt.length;
        if ((this.f == null) || (paramArrayOfInt == null) || (i1 <= 0))
            return;
        this.b.a(this.f, paramArrayOfInt[0], paramArrayOfInt[0], paramArrayOfInt[0]);
    }

    public void setBackBtn(a parama, int[] paramArrayOfInt) {
        c();
        this.k = parama;
        int i1 = paramArrayOfInt.length;
        if ((this.e == null) || (paramArrayOfInt == null) || (i1 <= 0))
            return;
        this.b.a(this.e, paramArrayOfInt[0], paramArrayOfInt[0], paramArrayOfInt[0]);
    }

    public static abstract interface a {
        public abstract void a(View paramView);
    }
}